#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtGui>
#include <QtWebKit>
#include "previewer.h"
#include "collector.h"

class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    MainWindow();

protected:
    void closeEvent(QCloseEvent *event);

private slots:
    void open();
    void openUrl();
    void LinkButton();
    void save();
    void about();
    void addPage();
    void showPage();
    void showHistory();
    void clearHistory();
    void openHistory(QString addr);
    void openPage(QString addr);

    void updateTextEdit();
    void updateWindowTitle(bool);
    void updateProgressBar(int);

    void backWebView();
    void forwardWebView();
private:
    Previewer *centralWidget;
    Collector *collector;
    Collector *history;
    QMap<QString,QString> historyList;
    QMenu *fileMenu;
    QMenu *helpMenu;
    QMenu *collectMenu;
    QToolBar *toolBar;
    QPlainTextEdit *plainTextEdit;
    QAction *plainAct;
    QAction *openAct;
    QAction *openUrlAct;
    QAction *saveAct;
    QAction *exitAct;
    QAction *addcollectAct;
    QAction *showcollectAct;
    QAction *showhistoryAct;
    QAction *clearhistoryAct;
    QAction *aboutAct;

    QComboBox *addrBox;
    QCommandLinkButton *command;
    QLabel *msgLabel;
    QProgressBar *progressBar;

    QDockWidget *coll;
    QDockWidget *plain;
    QListWidget *list;
    void createActions();
    void createMenus();
    void setStartupText();
    void createToolBar();
    void createIcon();
    void createTab();

    QWebView *mainWebView;
protected slots:
    void tabChanged(int index);
    void removeTab(int index);

};

#endif // MAINWINDOW_H
